home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / f2c / may_5_92.lha / f2c.VMay_5_1992 / libI77 / rsli.c < prev    next >
C/C++ Source or Header  |  1992-05-07  |  1KB  |  82 lines

  1. #include "f2c.h"
  2. #include "fio.h"
  3. #include "lio.h"
  4.  
  5. extern flag lquit;
  6. extern int lcount;
  7. extern int l_read();
  8. extern char *icptr;
  9. extern char *icend;
  10. extern icilist *svic;
  11. extern int icnum, recpos;
  12. extern int (*l_getc)(), (*l_ungetc)();
  13.  
  14. int i_getc()
  15. {
  16.     if(recpos >= svic->icirlen) {
  17.         if (recpos++ == svic->icirlen)
  18.             return '\n';
  19.         z_rnew();
  20.         }
  21.     recpos++;
  22.     if(icptr >= icend) err(svic->iciend,(EOF),"endfile");
  23.     return(*icptr++);
  24.     }
  25.  
  26. int i_ungetc(ch)
  27.  int ch;
  28. {
  29.     if (--recpos == svic->icirlen)
  30.         return '\n';
  31.     if (recpos < -1)
  32.         err(svic->icierr,110,"recend");
  33.     /* *--icptr == ch, and icptr may point to read-only memory */
  34.     return *--icptr /* = ch */;
  35.     }
  36.  
  37.  static void
  38. c_lir(a)
  39.  icilist *a;
  40. {
  41.     extern int l_eof;
  42.     reading = 1;
  43.     external = 0;
  44.     formatted = 1;
  45.     svic = a;
  46.     L_len = a->icirlen;
  47.     recpos = -1;
  48.     icnum = recpos = 0;
  49.     cursor = 0;
  50.     l_getc = i_getc;
  51.     l_ungetc = i_ungetc;
  52.     l_eof = 0;
  53.     icptr = a->iciunit;
  54.     icend = icptr + a->icirlen*a->icirnum;
  55.     cf = 0;
  56.     curunit = 0;
  57.     }
  58.  
  59.  
  60. integer s_rsli(a) icilist *a;
  61. {
  62.     lioproc = l_read;
  63.     lquit = 0;
  64.     lcount = 0;
  65.     c_lir(a);
  66.     return(0);
  67.     }
  68.  
  69. integer e_rsli()
  70. { return 0; }
  71.  
  72. s_rsni(a)
  73.  icilist *a;
  74. {
  75.     cilist ca;
  76.     ca.ciend = a->iciend;
  77.     ca.cierr = a->icierr;
  78.     ca.cifmt = a->icifmt;
  79.     c_lir(a);
  80.     return x_rsne(&ca);
  81.     }
  82.